package com.java.controller;

import com.java.entity.vo.WeChatAddMaterialResponse;
import com.java.service.WeChatMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/wechat/material")
public class WeChatMaterialController {

    @Autowired
    private WeChatMaterialService materialService;

    /**
     * 上传永久素材（仅保留 access_token、type、media）
     * @param accessToken 微信 access_token（query参数）
     * @param type 媒体类型（image/video/voice/thumb，query参数）
     * @param media 媒体文件（form-data文件）
     */
    @PostMapping("/add")
    public String addMaterial(
            @RequestParam("access_token") String accessToken,
            @RequestParam("type") String type,
            @RequestParam("media") String media
    ) throws Exception {
        return materialService.uploadMaterial(accessToken, type, media).getMedia_id();
    }
}